/*
 * Group:PrePool K9-357 
 * 8/2010
 */
package control;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletSession;

import org.apache.log4j.Logger;

import blo.ApproveBLO;
import blo.ManagerindictBLO;
import form.ManageHome;
import form.S09Form;
import form.S13Form;
import form.S14Form;

public class ReviewerCheckSuggestion extends BaseControl {

	/**
	 * 
	 */
	Logger LOG = Logger.getLogger("control.ApproverCheckSuggestion");
	private static final long serialVersionUID = 1L;
	public S09Form procApprove(ActionRequest request, ActionResponse response)
			throws PortletException, IOException {
		//create bean to store var
		LOG.debug("AAAAAAAAAAAAAA");
		S09Form result = new S09Form();
		//Retrieve needed info 
		int dictID = Integer.valueOf(request.getParameter("dictID"));
		result.setDicID(dictID);
		result.setDestination("/WEB-INF/jsp/S13_Reviewer_CheckSuggestion.jsp");
		String[] wIDs = request.getParameterValues("wordID");
		String username = request.getParameter("username");
		ApproveBLO aBLO = new ApproveBLO();
		// Print all array
		
		//calling approve for all checked word
		
		for(int i=0; i<wIDs.length;i++){
			LOG.info(Integer.valueOf(wIDs[i]));
			LOG.info(username);
			aBLO.approve(Integer.valueOf(wIDs[i]), username);
		}
		aBLO.approve(3, username);

		return result;
	}
	
	public ManageHome procBack(ActionRequest request, ActionResponse response)
				throws PortletException, IOException {
		String username = (String) request.getPortletSession().getAttribute("username", PortletSession.APPLICATION_SCOPE);
		LOG.info(username);
		int userrole = (Integer) request.getPortletSession().getAttribute("userrole", PortletSession.APPLICATION_SCOPE);
		blo.UsersBLO loginUser = new blo.UsersBLO();
		blo.ManagerindictBLO manageBLO = new ManagerindictBLO();
		ManageHome result = new ManageHome();
		
		result.setApproverManager(manageBLO.getApproverManagement(username));
		result.setReviewerManager(manageBLO.getReviewerManagement(username));
		result.setLoginUsername(username);
		result.setRole(userrole);
		return result;

}
	

}
